package com.aat.dxfy.protobuf.test1;

import java.net.ServerSocket;
import java.net.Socket;

import com.aat.dxfy.protobuf.test1.proto.Mobile;
import com.aat.dxfy.protobuf.test1.proto.Mobile.MobilePhone;

public class ServerTest {

	private static ServerSocket serverSock;

	public static void main(String[] args) throws Exception {
		serverSock = new ServerSocket(3030);
		while (true) {
			Socket sock = serverSock.accept();
			System.out.println("------------------");
			byte[] msg = new byte[256];
			sock.getInputStream().read(msg);
			int msgBodyLen = msg[0];
			System.out.println("msg body len:" + msgBodyLen);
			byte[] msgbody = new byte[msgBodyLen];
			System.arraycopy(msg, 1, msgbody, 0, msgBodyLen);
			MobilePhone phone = Mobile.MobilePhone.parseFrom(msgbody);
			System.out.println("Receive:");
			System.out.println(phone.toString());
		}
	}

}
